package cn.com.shopec.erp.product.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

import cn.com.shopec.erp.common.constant.SZSCMConstant;
import cn.com.shopec.erp.common.utils.LogicUtil;
import cn.com.shopec.erp.product.dao.ISpecValOptionDao;
import cn.com.shopec.erp.product.entity.SpecValOption;
import cn.com.shopec.erp.product.service.ISpecValOptionService;

@Service
public class SpecValOptionServiceImpl implements ISpecValOptionService{

	@Resource
	private ISpecValOptionDao specValOptionDao;
	
	@Override
	public SpecValOption getSpecValOption(String optionName) {
		SpecValOption product = null;
	        DetachedCriteria criteria = this.specValOptionDao.createCriteria();
	        criteria.add(Restrictions.eq("optionName", optionName));
	        criteria.add(Restrictions.eq("deleteFlag", SZSCMConstant.DELETE_FLAG_NO));
	        List<SpecValOption> productList = this.specValOptionDao.findByCriteria(criteria);
	        if (LogicUtil.isNotNullAndEmpty(productList)) {
	            product = productList.get(0);
	        }
	        return product;
	}

}
